define(['../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','bizProxy', function($scope,$location,$interval,$timeout,bizProxy) {
    	$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','loan'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','59'); 	//显示底部文字
    	
    	$scope.showInvest = false;

        queryCaseInfoList();
    	function queryCaseInfoList(){
        	var headerInfo = {},bizInfo = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;

    		$scope.$emit("loadingChange",true);
    		bizProxy.queryProxyBizData("queryCaseInfoList",headerInfo,bizInfo,
    				function(tempData){//SUCCESS
    					$scope.$emit("loadingChange",false);
						$timeout(function(){
							var caseInfoList = JSON.parse(tempData.body).caseInfoList;
                            console.log(caseInfoList);
                            if(caseInfoList.length > 0 ){
                                $scope.caseInfoList = caseInfoList;
                            }else{
                                $scope.showInvest = true;
                            }
						},100);
		    		},function(data){
    					console.log(data)
		    			if(data != ""){//FAIL
		    				$scope.$emit("loadingChange",false);
							if(data.errorCode == ERROR_CODE.noLogin){
								FIREFLY("", data.errorMsg,"",function(){
										//调用退出登录
										transData.mobileNo = "";
		    							transData.password = "";
		    							transData.sessionId = "";
		    							transData.userType = "";
		    							resultData.loginUserData = "";
		    							resultData.loginResultData = "";
		    							$timeout(function(){
		    								$scope.$emit("goNext","/mine");
		    							},0);
								});
							}else{
								$scope.showInvest = true;
								$scope.$emit("promptAlertMsg",data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
								},transData.promptTime);
							}
		    			}else{
		    				$scope.showInvest = true;
		    				$scope.$emit("loadingChange",false);
							$scope.$emit("promptAlertMsg","连接超时");
							$scope.$emit("showCollect",true);
							$timeout(function(){
								$scope.$emit("showCollect",false);
							},transData.promptTime);
		    			}
		    		});
        }
    	
    	//点击进入申请详情
    	$scope.goInvestDetail = function(data){
    		//保存数据
    		bodyInfo.investAloneData = data;
    		bodyInfo.caseId = data.caseId;
    		$scope.$emit("goNext","/investDetail");
    	}
    	
        $scope.$apply();
    }];
});